﻿using System.ComponentModel.DataAnnotations;
using System.Reflection;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using User.Global.Tests.Helper.Common;
using User.Web.Common.WebAttributes;
using User.Web.Models.Account;

namespace User.Web.UI.Tests.Unit.ModelTests
{
    [TestClass]
    public class LoginModelTest
    {
        #region Property Tests
        /// <summary>
        /// Prüft ob alle wichtigen Attribute des Passwort Properties
        /// </summary>
        [TestMethod]
        public void Attribute_CheckForProperty_Password()
        {
            //Sucht alle Properties unseres Models heraus.
            PropertyInfo propertyInfo = typeof(RegisterModel).GetProperty("Password");
            Assert.IsTrue(propertyInfo.HasDataType(DataType.Password));
            Assert.IsTrue(propertyInfo.HasAttribute<RequiredAttribute>());
            Assert.IsTrue(propertyInfo.HasAttribute<DisplayAttribute>());
            Assert.IsTrue(propertyInfo.HasAttribute<HtmlAttributesAttribute>());
        }

        /// <summary>
        /// Prüft ob alle wichtigen Attribute des Username Properties
        /// </summary>
        [TestMethod]
        public void Attribute_CheckForProperty_Username()
        {
            //Sucht alle Properties unseres Models heraus.
            PropertyInfo propertyInfo = typeof(RegisterModel).GetProperty("Username");
            Assert.IsTrue(propertyInfo.HasDataType(DataType.EmailAddress));
            Assert.IsTrue(propertyInfo.HasAttribute<RequiredAttribute>());
            Assert.IsTrue(propertyInfo.HasAttribute<DisplayAttribute>());
            Assert.IsTrue(propertyInfo.HasAttribute<HtmlAttributesAttribute>());
        }
        #endregion
    }
}
